//
//  BIDRepairKindViewController.m
//  HJGJCommunity
//
//  Created by mal on 2017/6/1.
//  Copyright © 2017年 mal. All rights reserved.
//

#import "BIDRepairKindViewController.h"
#import "BIDCommonRepairListViewController.h"


@interface BIDRepairKindViewController ()<UITableViewDelegate, UITableViewDataSource>
{
    NSArray *_dataSourceArr;
}
@end

@implementation BIDRepairKindViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"报修";
    _dataSourceArr = @[@{@"title":@"公共报修", @"className":@"BIDCommonRepairListViewController", @"isNeedXib":@0},
                       @{@"title":@"个人报修", @"className":@"BIDPersonalRepairViewController", @"isNeedXib":@1}];
    _tableView.tableFooterView = [[UIView alloc] init];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataSourceArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = nil;
    static NSString *identifier = @"identifier";
    NSUInteger row = indexPath.row;
    cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if(!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    NSDictionary *dic = _dataSourceArr[row];
    cell.textLabel.text = dic[@"title"];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSDictionary *dic = _dataSourceArr[indexPath.row];
    NSNumber *value = dic[@"isNeedXib"];
    NSString *strClassName = dic[@"className"];
    UIViewController *vc;
    if([value intValue] == 0)
    {
        vc = [[NSClassFromString(strClassName) alloc] init];
    }
    else
    {
        vc = [[NSClassFromString(strClassName) alloc] initWithNibName:strClassName bundle:nil];
    }
    [self.navigationController pushViewController:vc animated:YES];
}

@end
